Skip to content

Add WithAcceptOnlyJSONContentType method to set AcceptContentTypes to rest config#33

Merged
ldmonster merged 1 commit intomasterfrom
accept-only-json-content-type
Feb 12, 2026
Merged

Add WithAcceptOnlyJSONContentType method to set AcceptContentTypes to rest config#33
ldmonster merged 1 commit intomasterfrom
accept-only-json-content-type

Conversation

@name212
Copy link
Copy Markdown
Contributor

@name212 name212 commented Feb 11, 2026

Overview

Add WithAcceptOnlyJSONContentType method to set AcceptContentTypes to rest config to report API-server
to send response in JSON format.

In some products (like dhctl in deckhouse) we are logging all requests and responses to debug log file.
But API server often send response in protobuf format like this:

2026-02-11 18:08:57 - klog: I0211 18:08:57.877297   20161 round_trippers.go:584] Response Headers:
2026-02-11 18:08:57 - klog: I0211 18:08:57.877310   20161 round_trippers.go:587]     Audit-Id: d68d3383-dfd1-4734-93c4-39fd4b19073f
2026-02-11 18:08:57 - klog: I0211 18:08:57.877321   20161 round_trippers.go:587]     Cache-Control: no-cache, private
2026-02-11 18:08:57 - klog: I0211 18:08:57.877406   20161 round_trippers.go:587]     Content-Type: application/vnd.kubernetes.protobuf
2026-02-11 18:08:57 - klog: I0211 18:08:57.877415   20161 round_trippers.go:587]     Date: Wed, 11 Feb 2026 18:08:57 GMT
2026-02-11 18:08:57 - klog: I0211 18:08:57.877421   20161 round_trippers.go:587]     X-Kubernetes-Pf-Flowschema-Uid: cb6143bf-2e72-40ec-9530-8f45641e9905
2026-02-11 18:08:57 - klog: I0211 18:08:57.877429   20161 round_trippers.go:587]     X-Kubernetes-Pf-Prioritylevel-Uid: 6300b971-a35b-447f-90e2-f9031dc9e617
2026-02-11 18:08:57 - klog: I0211 18:08:57.887635   20161 type.go:168] "Response Body" body=<
        00000000  6b 38 73 00 0a 0c 0a 02  76 31 12 06 53 65 63 72  |k8s.....v1..Secr|
        00000010  65 74 12 ef 20 0a f2 02  0a 21 64 38 2d 70 72 6f  |et.. ....!d8-pro|
        00000020  76 69 64 65 72 2d 63 6c  75 73 74 65 72 2d 63 6f  |vider-cluster-co|

This log is multiline and huge. It is bad for obseravbility logs. Also it is complex to analyse response because output is formatted bytes.

Also, we added WithLogger method to set logger after creating Client

What this PR does / why we need it

Special notes for your reviewer

Does this PR introduce a user-facing change?


… rest config for getting all responses from API-server in json format
@name212 name212 requested a review from ldmonster February 11, 2026 18:53
@ldmonster ldmonster merged commit 9992715 into master Feb 12, 2026
3 checks passed
@ldmonster ldmonster deleted the accept-only-json-content-type branch February 12, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants